package com.hq.cms.web.controllers;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hq.cms.domain.Category;
import com.hq.cms.domain.Channel;
import com.hq.cms.service.ChannelCategoryService;

/**
 * 
 * 当前控制层就是处理 分类及频道的控制层
 *
 */
@Controller
public class ChannelAndCategoryController {
	@Resource
	private ChannelCategoryService channelCategoryService;
	// 加载 频道列表
	// 因为用到了ajax 所以 需要两个注解
	@RequestMapping("/channelList")
	@ResponseBody
	public Object channelList() {
		// 获取 频道列表(CMS项目已提供相关方法 直接调用)
		List<Channel> channels = channelCategoryService.getChannels();
		return channels;
	}
	
	@RequestMapping("/categoryListByChannelId")
	@ResponseBody
	public Object categoryListByChannelId(Integer channel_id) {
		// 通过频道的id  获取  类型列表
		List<Category> categories = channelCategoryService.getCategories(channel_id);
		return categories;
	}
}
